<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>016_00防抖的原理和使用</title>
</head>
<body>
  
</body>
<script>
  var timerId
  var resizeSum = 0
  window.addEventListener('resize', function () {

    if (timerId) {
      clearTimeout(timerId)
      timerId = null
    }
    timerId = setTimeout(() => {
      console.log('浏览器的窗口改变了')
      resizeSum = resizeSum + 1
    }, 500)
  })
</script>
</html>